// http://pcapi-xiaotuxian-front-devtest.itheima.net/
import axios from "axios";
const httpInstance = axios.create({
  baseURL: "http://pcapi-xiaotuxian-front-devtest.itheima.net",
  timeout: 50000,
});

// axios请求拦截器
httpInstance.interceptors.request.use(config => {
  // 1.从store获取token
  // const token = window.localStorage.getItem("token")
  // // 2.请求头添加token
  // if (token) {
  //   config.headers.Authorization = `Bearer ${token}`
  // }
  return config
},e => Promise.reject(e))

// axios响应式拦截器
httpInstance.interceptors.response.use(res => res.data,e => {
    return Promise.reject(e)
})

export default httpInstance;